#!/bin/bash

mkdir -p /Volumes/nas/opt/minio/config
mkdir -p /Volumes/nas/opt/minio/data

docker rm -f minio
docker run -d --name minio --restart always \
  -p 9000:9000 \
  -e MINIO_ACCESS_KEY=admin \
  -e MINIO_SECRET_KEY=6wq0uXWaUS3iMo7l \
  -v /opt/minio/data:/data \
  -v /opt/minio/config:/root/.minio \
  minio/minio server \
  /data --console-address ":9000" -address ":9090"

docker rm -f minio
docker run -d --name minio --restart always \
  -p 9000:9000 \
  -p 9090:9090 \
  -e MINIO_ACCESS_KEY=admin \
  -e MINIO_SECRET_KEY=6wq0uXWaUS3iMo7l \
  -v /tmp/zfsv2/zenith_sata/18667191781/data/docker/minio/data:/data \
  -v /tmp/zfsv2/zenith_sata/18667191781/data/docker/minio/config:/root/.minio \
  minio/minio server \
  /data --console-address ":9000" -address ":9090"

# https配置。必须重命名，可能需要改权限
mv fullchain.pem public.crt
mv privkey.pem private.key

chmod 644 /path/to/certs/public.crt
chmod 600 /path/to/certs/private.key
chown -R 1001:1001 /path/to/certs  # MinIO 容器默认用户UID=1001

docker run -d \
  --name minio \
  -p 9000:9000 \
  -p 9090:9090 \
  -v /path/to/data:/data \
  -v /path/to/certs:/root/.minio/certs \  # 确保证书目录挂载
  -e "MINIO_ROOT_USER=admin" \
  -e "MINIO_ROOT_PASSWORD=yourpassword" \
  minio/minio server \
  --address ":9000" \
  --console-address ":9090" \
  --certs-dir /root/.minio/certs \  # 显式指定证书目录
  /data